home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1993 / Internet Info CD-ROM (Walnut Creek) (1993).iso / networking / terms / tip / tip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-28  |  7.8 KB  |  285 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  *
  17.  *    @(#)tip.h    5.4 (Berkeley) 9/2/88
  18.  */
  19.  
  20. /*
  21.  * tip - terminal interface program
  22.  */
  23.  
  24. #include <sys/types.h>
  25. #include <sys/file.h>
  26.  
  27. #include <sgtty.h>
  28. #include <signal.h>
  29. #include <stdio.h>
  30. #include <pwd.h>
  31. #include <ctype.h>
  32. #include <setjmp.h>
  33. #include <errno.h>
  34. #include <netdb.h>
  35. #include <string.h>
  36.  
  37. #if    defined(SUNOS4) || defined(__ANSI__) || defined(sparc)
  38. typedef void sigfunc_t;
  39. #else
  40. typedef int sigfunc_t;
  41. #endif
  42.  
  43. /*
  44.  * Remote host attributes
  45.  */
  46. char    *DV;            /* UNIX device(s) to open */
  47. char    *EL;            /* chars marking an EOL */
  48. char    *CM;            /* initial connection message */
  49. char    *IE;            /* EOT to expect on input */
  50. char    *OE;            /* EOT to send to complete FT */
  51. char    *CU;            /* call unit if making a phone call */
  52. char    *AT;            /* acu type */
  53. char    *PN;            /* phone number(s) */
  54. char    *DI;            /* disconnect string */
  55. char    *PA;            /* parity to be generated */
  56.  
  57. char    *PH;            /* phone number file */
  58. char    *RM;            /* remote file name */
  59. char    *HO;            /* host name */
  60.  
  61. char    *SA;            /* local slip address */
  62. char    *DA;            /* destination slip address */
  63. char    *SM;            /* netmask for slip */
  64. char    *ST;            /* slip type */
  65. char    *LS;            /* login script file */
  66.  
  67. int    BR;            /* line speed for conversation */
  68. int    FS;            /* frame size for transfers */
  69.  
  70. char    DU;            /* this host is dialed up */
  71. char    HW;            /* this device is hardwired, see hunt.c */
  72. char    *ES;            /* escape character */
  73. char    *EX;            /* exceptions */
  74. char    *FO;            /* force (literal next) char*/
  75. char    *RC;            /* raise character */
  76. char    *RE;            /* script record file */
  77. char    *PR;            /* remote prompt */
  78. int    DL;            /* line delay for file transfers to remote */
  79. int    CL;            /* char delay for file transfers to remote */
  80. int    ET;            /* echocheck timeout */
  81. char    HD;            /* this host is half duplex - do local echo */
  82.  
  83. /*
  84.  * String value table
  85.  */
  86. typedef
  87.     struct {
  88.         char    *v_name;    /* whose name is it */
  89.         char    v_type;        /* for interpreting set's */
  90.         char    v_access;    /* protection of touchy ones */
  91.         char    *v_abrev;    /* possible abreviation */
  92.         char    *v_value;    /* casted to a union later */
  93.     }
  94.     value_t;
  95.  
  96. #define STRING    01        /* string valued */
  97. #define BOOL    02        /* true-false value */
  98. #define NUMBER    04        /* numeric value */
  99. #define CHAR    010        /* character value */
  100.  
  101. #define WRITE    01        /* write access to variable */
  102. #define    READ    02        /* read access */
  103.  
  104. #define CHANGED    01        /* low bit is used to show modification */
  105. #define PUBLIC    1        /* public access rights */
  106. #define PRIVATE    03        /* private to definer */
  107. #define ROOT    05        /* root defined */
  108.  
  109. #define    TRUE    1
  110. #define FALSE    0
  111.  
  112. #define ENVIRON    020        /* initialize out of the environment */
  113. #define IREMOTE    040        /* initialize out of remote structure */
  114. #define INIT    0100        /* static data space used for initialization */
  115. #define TMASK    017
  116.  
  117. /*
  118.  * Definition of ACU line description
  119.  */
  120. typedef
  121.     struct {
  122.         char    *acu_name;
  123.         int    (*acu_dialer)();
  124.         int    (*acu_disconnect)();
  125.         int    (*acu_abort)();
  126.     }
  127.     acu_t;
  128.  
  129. #define    equal(a, b)    (strcmp(a,b)==0)/* A nice function to string compare */
  130.  
  131. /*
  132.  * variable manipulation stuff --
  133.  *   if we defined the value entry in value_t, then we couldn't
  134.  *   initialize it in vars.c, so we cast it as needed to keep lint
  135.  *   happy.
  136.  */
  137. typedef
  138.     union {
  139.         int    zz_number;
  140.         short    zz_boolean[2];
  141.         char    zz_character[4];
  142.         int    *zz_address;
  143.     }
  144.     zzhack;
  145.  
  146. #define value(v)    vtable[v].v_value
  147.  
  148. #define number(v)    ((((zzhack *)(&(v))))->zz_number)
  149. #ifdef vax
  150. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[0])
  151. #define character(v)    ((((zzhack *)(&(v))))->zz_character[0])
  152. #else
  153. #define boolean(v)    ((((zzhack *)(&(v))))->zz_boolean[1])
  154. #define character(v)    ((((zzhack *)(&(v))))->zz_character[3])
  155. #endif
  156. #define address(v)    ((((zzhack *)(&(v))))->zz_address)
  157.  
  158. /*
  159.  * Escape command table definitions --
  160.  *   lookup in this table is performed when ``escapec'' is recognized
  161.  *   at the begining of a line (as defined by the eolmarks variable).
  162. */
  163.  
  164. typedef
  165.     struct {
  166.         char    e_char;        /* char to match on */
  167.         char    e_flags;    /* experimental, priviledged */
  168.         char    *e_help;    /* help string */
  169.         int     (*e_func)();    /* command */
  170.     }
  171.     esctable_t;
  172.  
  173. #define NORM    00        /* normal protection, execute anyone */
  174. #define EXP    01        /* experimental, mark it with a `*' on help */
  175. #define PRIV    02        /* priviledged, root execute only */
  176.  
  177. extern int    vflag;        /* verbose during reading of .tiprc file */
  178. extern value_t    vtable[];    /* variable table */
  179.  
  180. #ifndef ACULOG
  181. #define logent(a, b, c, d)
  182. #define loginit()
  183. #endif
  184.  
  185. /*
  186.  * Definition of indices into variable table so
  187.  *  value(DEFINE) turns into a static address.
  188.  */
  189.  
  190. #define BEAUTIFY    0
  191. #define BAUDRATE    1
  192. #define DIALTIMEOUT    2
  193. #define EOFREAD        3
  194. #define EOFWRITE    4
  195. #define EOL        5
  196. #define ESCAPE        6
  197. #define EXCEPTIONS    7
  198. #define FORCE        8
  199. #define FRAMESIZE    9
  200. #define HOST        10
  201. #define LOG        11
  202. #define PHONES        12
  203. #define PROMPT        13
  204. #define RAISE        14
  205. #define RAISECHAR    15
  206. #define RECORD        16
  207. #define REMOTE        17
  208. #define SCRIPT        18
  209. #define TABEXPAND    19
  210. #define VERBOSE        20
  211. #define SHELL        21
  212. #define HOME        22
  213. #define ECHOCHECK    23
  214. #define DISCONNECT    24
  215. #define TAND        25
  216. #define LDELAY        26
  217. #define CDELAY        27
  218. #define ETIMEOUT    28
  219. #define RAWFTP        29
  220. #define HALFDUPLEX    30
  221. #define    LECHO        31
  222. #define    PARITY        32
  223. #define    SLIPADDR    33
  224. #define SLIPDSTADDR    34
  225. #define    SLIPMASK    35
  226. #define    SLIPTYPE    36
  227. #define LOGINSCRIPT    37
  228. #define    SETROUTE    38
  229. #define LINESYNC        39
  230. #define DTRHUP        40
  231.  
  232. #define NOVAL    ((value_t *)NULL)
  233. #define NOACU    ((acu_t *)NULL)
  234. #define NOSTR    ((char *)NULL)
  235. #define NOFILE    ((FILE *)NULL)
  236. #define NOPWD    ((struct passwd *)0)
  237.  
  238. struct sgttyb    arg;        /* current mode of local terminal */
  239. struct sgttyb    defarg;        /* initial mode of local terminal */
  240. struct tchars    tchars;        /* current state of terminal */
  241. struct tchars    defchars;    /* initial state of terminal */
  242. struct ltchars    ltchars;    /* current local characters of terminal */
  243. struct ltchars    deflchars;    /* initial local characters of terminal */
  244.  
  245. FILE    *fscript;        /* FILE for scripting */
  246.  
  247. int    fildes[2];        /* file transfer synchronization channel */
  248. int    repdes[2];        /* read process sychronization channel */
  249. int    FD;            /* open file descriptor to remote host */
  250. int    AC;            /* open file descriptor to dialer (v831 only) */
  251. int    vflag;            /* print .tiprc initialization sequence */
  252. int    sfd;            /* for ~< operation */
  253. int    pid;            /* pid of tipout */
  254. uid_t    uid, euid;        /* real and effective user id's */
  255. gid_t    gid, egid;        /* real and effective group id's */
  256. int    stop;            /* stop transfer session flag */
  257. int    quit;            /* same; but on other end */
  258. int    stoprompt;        /* for interrupting a prompt session */
  259. int    timedout;        /* ~> transfer timedout */
  260. int    cumode;            /* simulating the "cu" program */
  261. int    slip;            /* bring up SLIP on the line */
  262.  
  263. char    fname[80];        /* file name buffer for ~< */
  264. char    copyname[80];        /* file name buffer for ~> */
  265. char    ccc;            /* synchronization character */
  266. char    uucplock[];        /* name of lock file for uucp's */
  267.  
  268. int    odisc;                /* initial tty line discipline */
  269. extern    int disc;            /* current tty discpline */
  270.  
  271. extern    char *ctrl();
  272. extern    char *ctime();
  273. extern    long time();
  274. extern    struct passwd *getpwuid();
  275. extern    char *getlogin();
  276. extern    char *vinterp();
  277. extern    char *getenv();
  278. extern    char *rindex();
  279. extern    char *index();
  280. extern    char *malloc();
  281. extern    char *lconnect();
  282.  
  283. #undef CTRL
  284. #define    CTRL(c)    ((c)&037)
  285.